package com.zb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjInstructionBooklContent;
import com.zb.mapper.ZjInstructionBooklContentMapper;
import com.zb.service.ZjInstructionBooklContentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 产品说明书内容表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2023-07-31
 */
@Service
public class ZjInstructionBooklContentServiceImpl extends ServiceImpl<ZjInstructionBooklContentMapper, ZjInstructionBooklContent> implements ZjInstructionBooklContentService {
    @Resource
    private ZjInstructionBooklContentMapper instructionBooklContentMapper;

    // 保存或更新说明书内容
    @Override
    public void save(Long custAccId, Long id, String content) {
        if (null != this.getById(id)) {
            ZjInstructionBooklContent ibc = new ZjInstructionBooklContent();
            ibc.setId(id);
            ibc.setCustAccId(custAccId);
            ibc.setContent(content);
            this.updateById(ibc);
            return;
        }
        ZjInstructionBooklContent ibc = new ZjInstructionBooklContent();
        ibc.setId(id);
        ibc.setCustAccId(custAccId);
        ibc.setContent(content);
        this.save(ibc);
    }

    // 根据ID获取说明书内容
    @Override
    public String getContentById(Long id) {
        return instructionBooklContentMapper.getContentById(id);
    }
}
